import React from "react";
import Block from "./Block";
import {
    getNowStep,
    isWin,
    full
} from "./utils"

const mapping = {
    0:' ',
    1:'X',
    2:'O'
}

class Board extends React.Component{
    constructor(props) {
        super(props);
        //this.props.nowMap;
        // this.props.toFather;
        this.childrenClick = this.childrenClick.bind(this);
    }
    childrenClick(position){
        this.props.toFather(position);
    }
    render() {
        let blocklist = this.props.nowMap.map(
            (data,index) =>
            {
            return <Block toFather={this.childrenClick}  key={index} isClickable={!(isWin(this.props.nowMap) || this.props.nowMap[index] !== 0)} state={this.props.nowMap[index]} position={index}> </Block>
        })
        return (
            <div className="Board">
                {blocklist}
            </div>
        )
    }
}

export default Board;